/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Grid = require("grid");
	var aw = require("ajaxwrapper");
    var instance = {
        initComponent: function (params,widget) {
        	var grid = new Grid({
        		parentNode: ".J-grid",
        		model:{
        			url:"api/goods/query",
        			params:function(){
        				var subnav = widget.get("subnav");
        				return{
        					fetchProperties:"pkGoods,name,version,description"
        				}
        				
        			},
        			columns:[{
        				name:"name",
        				label:"名称"
        			},{
        				name:"description",
        				label:"备注"
        			},{
        				name:"operate",
        				label:"操作",
        				format:"button",
        				formatparams:[{
        					id:"edit",
        					text:"修改",
//        					show:function(index,data,rowEle){
//								
//        						if(data.driverStatus.key=="Passage"){
//        							return false;
//        						} else {
//        							return true;
//        						}
//        						
//							},
        					handler:function(index,data,rowEle){
        						widget.get("subnav").hide(["search","add"]);	
        						widget.get("form").setData(data);
        						widget.hide([".J-grid"]).show([".J-form"]);
        					}
        				},{
        					id:"delete",
        					text:"删除",
        					handler:function(index,data,rowEle){
								aw.del("api/goods/"+data.pkGoods+"/delete",function() {
									grid.refresh();
								});	
							}
        				}]
        			},]
        		},
        		
        	});
        	widget.set("grid",grid)
        }
    };
    module.exports = instance;
});
